
import Framework.*;



import java.awt.BorderLayout;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import Framework.debugMessage;

public class frame_Hardware extends JPanel{
	static String CLASS = "pane_Hardware"; 

	
	/*
	 * Hardware based variables
	 * -1 is nonexistant
	 * 0  is existant
	 * 1  is in use 
	 */
	
	int 	ii_DVD = -1;
	boolean ib_isDvd = false; // false if music cd, true if dvd. 
	
	int 	ii_usb = -1;
	int		ii_aux = -1;
	
	boolean	ib_passengers = false; // True if car has passengers
	boolean ib_seatbeltOnDriver = true; // False if driver not wearing seatbelt
	boolean ib_seatbeltOnPassenger = true; // False if one or more passengers have seatbelts off
	
	int		ii_wifi = -1;
	int		ii_bluetooth = -1;
	
	int		ii_phoneCall = -1;
	int		ii_textMessages = -1;
	int		ii_email = -1;
	
	boolean	ib_NeedsService = false;
	
	
	boolean ii_oilPressureOK = true;
	boolean ii_fuelOK = true;
	
	boolean ib_carMoving = false;
	
	boolean ib_hapticFeedback = false;
	
	JPanel 		vis_layout		 	= new JPanel();
	
	
	JButton			btn_phone_RecieveSMS = new JButton("Recieve SMS Message");
	JButton			btn_phone_RecieveEmail = new JButton("Recieve Email");
	
	JButton			btn_wifi_FindAccessPoint = new JButton("Find a new Access point");
	JButton			btn_wifi_FindKnownAccessPoint = new JButton("Find a known Access point");
	JButton			btn_wifi_LoseAccessPoint = new JButton("Lose access point");
	
	JButton			btn_bluetooth_RecievePaired = new JButton("Find a paired Bluetooth device");
	JButton			btn_bluetooth_RecieveNotPaired = new JButton("Find an unpaired Bluetooth device");
	JButton			btn_bluetooth_LosePaired = new JButton("Lose a bluetooth device");
	JButton			btn_phone_RecievePhone = new JButton("Recieve Phone Call");
	
	JTextArea		mle_debugMessages = new JTextArea(5, 60);
	
	
	JScrollPane		scroll_debugMessages = new JScrollPane(mle_debugMessages);
	
	private void helloWorld(){
		String METHOD = "helloWorld()";
		debugMessage.log(CLASS + "." + METHOD + " Called.", 10);
 
		

		debugMessage.log(CLASS + "." + METHOD + " Finished.", 10);
		
	}
	public JPanel getPanel(){
		String METHOD = "getPanel()";
		debugMessage.log(CLASS + "." + METHOD + " Called.", 10);
		return vis_layout;
	}
	
	class eventHandler implements ActionListener{
		String CLASS = "pane_Hardware.eventHandler";
			
		public void actionPerformed(ActionEvent e){
			String METHOD = "actionPerformed(ActionEvent e)";
			debugMessage.log(CLASS + "." + METHOD + " Called.", 10);
			
			Object ActionObject = e.getSource();
			if (ActionObject.equals(btn_phone_RecievePhone)){
				debugMessage.log("Ring Ring!", 40);
			}
			else if (ActionObject.equals(btn_phone_RecieveSMS)){
				debugMessage.log("SMS!", 40);
			}
			
			
			debugMessage.log(CLASS + "." + METHOD + " Finished.", 10);
		}		
	}
	
	frame_Hardware(){
		String METHOD = "pane_Hardware()";
		debugMessage.log(CLASS + "." + METHOD + " Called.", 10);
		
		mle_debugMessages.setEditable(false);
	
		
		eventHandler myEvents = new eventHandler(); 
		
		btn_phone_RecievePhone.addActionListener(myEvents);
		btn_phone_RecieveSMS.addActionListener(myEvents);
		//btn_phone_RecievePhone.setActionCommand(this.helloWorld());
		vis_layout.add(btn_phone_RecievePhone, BorderLayout.NORTH);
		vis_layout.add(btn_phone_RecieveSMS, BorderLayout.NORTH);
		vis_layout.add(btn_phone_RecieveEmail, BorderLayout.NORTH);
		vis_layout.add(btn_wifi_FindAccessPoint, BorderLayout.NORTH);
		vis_layout.add(btn_wifi_FindKnownAccessPoint, BorderLayout.NORTH);
		vis_layout.add(btn_wifi_LoseAccessPoint, BorderLayout.NORTH);
		vis_layout.add(btn_bluetooth_RecievePaired, BorderLayout.NORTH);
		vis_layout.add(btn_bluetooth_RecieveNotPaired, BorderLayout.NORTH);
		vis_layout.add(btn_bluetooth_LosePaired, BorderLayout.NORTH);
		vis_layout.add(scroll_debugMessages, BorderLayout.SOUTH);
		//mle_debugMessages.setVisible(true);
		vis_layout.add(scroll_debugMessages);
		scroll_debugMessages.setMaximumSize(vis_layout.getMaximumSize());
		//scroll_debugMessages.add(mle_debugMessages);
		//scroll_debugMessages.
		//scroll_debugMessages.setVisible(true);
		debugMessage.mleRegister(mle_debugMessages);
	
		// Instantiate all hardware stuff.
		vis_layout.repaint();
		vis_layout.setVisible(true);
		
	
		debugMessage.log(CLASS + "." + METHOD + " Finished.", 10);
	}
	protected void finalize() throws Throwable
	{
		debugMessage.log("Object " + CLASS + " Destructed.", 11);
	}
}
